const positionSavedMap = new Map();
export default {
	activated(){
		const $pageView = this.$refs.pageView;
		if(!$pageView){
			return;
		}
		const routePath = this.$route.path;
		const savedPosition = positionSavedMap.get(routePath);
		if(savedPosition){
			if(this.$route.params['stack-key-dir'] === 'back'){
				positionSavedMap.delete(routePath);
				$pageView.scrollTo(savedPosition.x,savedPosition.y);
				console.log(routePath+":恢复滚动高度",savedPosition.y)
			}
		}
	},
	beforeRouteLeave (to, from, next) {
		const $pageView = this.$refs.pageView;
		if($pageView){
			const routePath = this.$route.path;
			positionSavedMap.set(routePath,{x:$pageView.scrollLeft,y:$pageView.scrollTop})
			console.log(routePath+":记录滚动位置",$pageView.scrollTop)
		}
		next()
	}
}